﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Ivy.Common.Framework.Base
{
    [Serializable]
    public enum EntityState
    {
        UnChanged = 0,
        New = 1,
        Changed = 2,
        Deleted = 3
    }

    

    [Serializable]
    [DataContract]
    public class DataEntityBase : EntityBase
    {
        #region Variables & Constants

        EntityState lEntityState = EntityState.UnChanged;
        DateTime lConcurrencyTimeStamp = DateTime.Now;

        #endregion Variables & Constants

        #region Constructor & Destructor
        public DataEntityBase() : base() 
        {
            this.EntityState = Base.EntityState.New;
        }
        #endregion Constructor & Destructor

        #region Public Properties
        [DataMember]
        public DateTime ConcurrencyTimeStamp
        {
            get
            {
                return lConcurrencyTimeStamp;
            }
            set
            {
                lConcurrencyTimeStamp = value;
            }
        }
        [DataMember]
        public EntityState EntityState
        {
            get
            {
                return lEntityState;
            }
            set
            {
                lEntityState = value;
            }
        }

        
        #endregion Public Properties

        #region Public Methods
       
        #endregion Public Methods

        #region Events
        #endregion Events

        #region Private Methods
        protected void SetEntityStateChangeAttribute()
        {
            if (lEntityState == Base.EntityState.UnChanged)
            {
                lEntityState = Base.EntityState.Changed;
            }
        }
        #endregion Private Methods

    }
}
